package com.chb.controller;

import com.chb.annotation.LogAnnotation;
import com.chb.model.entity.OutLibray;
import com.chb.model.vo.BranchGoodsVo;
import com.chb.model.vo.Result;
import com.chb.service.OutLibrayService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: 陈海彬
 * @date: Created in 2023/9/28 19:58
 * @description:
 * @modified By:
 * @version:
 */
@RestController
@RequestMapping("/outLibray")
public class OutLibrayController {

    @Autowired
    private OutLibrayService outLibrayService;

    /**
     * @param branchid 模糊查询的门店id
     * @param page     当前的页数
     * @param pageSize 每页展示的数量
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 查询该门店下的入库信息
     * @create time: 2023/9/28 20:01
     */
    @GetMapping("/getInformation")
    @LogAnnotation
    public Result getInformation(Integer branchid, Integer page, Integer pageSize) {
        return outLibrayService.getInformation(branchid, page, pageSize);
    }

    /**
     * @param branchGoodsVoList 入库商品vo数组
     * @param outmethod         零售或批量状态
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 进行批量添加入库商品
     * @create time: 2023/9/28 21:18
     */
    @PostMapping("/addOutLibray")
    @LogAnnotation(business_type = "添加出库商品")
    public Result addOutLibray(@RequestBody List<BranchGoodsVo> branchGoodsVoList, Integer outmethod) {
        return outLibrayService.addOutLibray(branchGoodsVoList, outmethod);
    }

    /**
     * @param page     当前页
     * @param pageSize 每页最大数
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 出库审核需要的数据
     * @create time: 2023/9/29 0:38
     */
    @GetMapping("/getWarehouseInfo")
    @LogAnnotation
    public Result getWarehouseInfo(Integer page, Integer pageSize, Integer branchid) {
        return outLibrayService.getWarehouseInfo(page, pageSize, branchid);
    }

    /**
     * @param cid 出库编号
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 根据出库编号查询出库详情
     * @create time: 2023/9/29 8:34
     */
    @GetMapping("/getOutInfoByCid")
    @LogAnnotation
    public Result getOutInfoByCid(Integer cid, Integer page, Integer pageSize) {
        return outLibrayService.getOutInfoByCid(cid, page, pageSize);
    }

    /**
     * @param outLibray 出库商品信息
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 对出库商品进行审核
     * @create time: 2023/9/29 9:13
     */
    @PostMapping("/warehouseAudit")
    @LogAnnotation(business_type = "出库审核商品")
    public Result warehouseAudit(@RequestBody OutLibray outLibray) {
        return outLibrayService.warehouseAudit(outLibray);
    }

    /**
     * @param branchGoodsVoList
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 获取当前商品库存是否满足平调或出库
     * @create time: 2023/10/12 20:35
     */
    @PostMapping("/getOutLibrayCount")
    @LogAnnotation
    public Result getOutLibrayCount(@RequestBody List<BranchGoodsVo> branchGoodsVoList) {
        return outLibrayService.getOutLibrayCount(branchGoodsVoList);
    }
}